package com.quan.amqp.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.quan.common.base.bean.LocationBean;
import com.quan.common.base.constant.CommonConstant;
import com.quan.common.utils.IpHelper;
import com.quan.feign.SystemLogService;
import com.quan.system.entity.SystemLog;

/**
 * RabbitMQ 主题模式
 * @author yhaoquan
 *
 */
@Component
@RabbitListener(queues = CommonConstant.MQ_TOPIC_MESSAGE_LOGGER)
public class TopicMessageLogListener {
	
	private Logger logger = LoggerFactory.getLogger(getClass()) ;
	
	@Autowired 
    private SystemLogService logService;
	
	@RabbitHandler
	public void processMessage(SystemLog entity) {
		logger.info("处理Topic队列消息==>>Logger日志消息保存>>>>>>>>");
		
		String amapKey = "2b7d6cf58cefb5511c218cf37d776ba0" ;
		LocationBean ipLocation = IpHelper.getIpLocation(amapKey, "119.131.116.15");
		
		entity.setIpLocation(ipLocation.getCity());
		this.logService.add(entity) ;
	}

}
